package com.metaera.app.controller.view;

import android.widget.Toast;

import com.metaera.app.MetaEraApplication;
import com.metaera.app.controller.view.core.INetworkRequestView;

public class BasicNetworkRequestView<T> implements INetworkRequestView<T> {

    private final INetworkRequestView<T> mINetworkRequestView;

    public BasicNetworkRequestView() {
        this(null);
    }

    public BasicNetworkRequestView(INetworkRequestView<T> mINetworkRequestView) {
        this.mINetworkRequestView = mINetworkRequestView;
    }

    @Override
    public void successful(T data) {
        if (mINetworkRequestView != null){
            mINetworkRequestView.successful(data);
        }
    }

    @Override
    public void loading() {

    }

    @Override
    public void failure(Throwable throwable) {
        throwable.printStackTrace();
        Toast.makeText(MetaEraApplication.sInstance, throwable.getMessage(), Toast.LENGTH_SHORT).show();
    }

}
